﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EWineShop.Service.Model;
using EWineShop.Service.Contracts;
using EWineShop.Service;

namespace EWineShop.AdminSite.Controllers
{
    public class FoodCategoryController : BaseController
    {
        IFoodCategoryService IFoodCategory = new FoodCategoryService();
        IIDCreaterService IIDCreater = new IDCreaterService();

        public ActionResult Index()
        {

            return View();
        }

        public ActionResult Save(FormCollection collection)
        {
            FoodCategoryModel model = new FoodCategoryModel()
            {
                FoodCategoryID = IIDCreater.GetNewID("FoodCategoryID","菜品类别ID",1000),
                Name = collection["txtName"],
                Remark = "",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Parse("1900-01-01")
            };

            IFoodCategory.AddFoodCategory(model);

            return null;
        }

        public ActionResult Update(FormCollection collection)
        {
            FoodCategoryModel model = new FoodCategoryModel()
            {
                FoodCategoryID = Int64.Parse(collection["HDfoodCategoryID"]),
                Name = collection["txtName"],
                Remark="",
                CreateTime=DateTime.Now,
                UpdateTime=DateTime.Now
            };

            IFoodCategory.UpdateByFoodCategoryID(model);

            return null;

        }

        public ActionResult Delete(Int64 id)
        {
            IFoodCategory.DeleteByFoodCategoryID(id);
            return null;
        }

    }
}
